<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>地点Block-缩影信息</title>
    <!--加载 缩影 CSS-->
    <link rel="stylesheet" href="public/css/block/address.css">
</head>
<body>
    <div class="container">
        <!--天气 Block-->
        <div class="Block" id="Block">
            <div class="address">
                <div class="address_distance">20 <span class="address_distance_min">公里<span style="color:#6c797a"> 到</span></span></div>
                <div class="address_title">
                    加载中...
                </div>
                <div class="address_map" id="address_map" >
                	load...
                </div>
            </div>
        </div>
    </div>
    
    <script type="text/javascript" defer>
 	    $(document).ready(function(){
	    	var address_title = json.soryin.blockId.address.detailed;	//获取详细地址
	    	var city = json.soryin.blockId.address.city;	//获取城市
	    	var address_map = city+json.soryin.blockId.address.detailed;	//组合详细地址
			$(".address_title").html(address_title);	//显示到html上
			
			getLocation();	//执行定位

			
			//判断浏览器是否支持定位
			function getLocation(){
				if (navigator.geolocation){
			    	navigator.geolocation.getCurrentPosition(showPosition);
			    }else{
					$(".address_map").html('<img alt="BaiduMap" src="http://api.map.baidu.com/staticimage?width=570&height=245&markers='+address_map+'&zoom=16&markerStyles=s,A,0xff0000" width="100%"/>');	//显示到html上
				}
			}
			//进行定位
			function showPosition(position){
				var latitude = position.coords.latitude;		//纬度
				var longitude = position.coords.longitude;		//经度
				var address = new BMap.Point(longitude,latitude);
				// 百度地图API功能
				var map = new BMap.Map("address_map");
				map.centerAndZoom(new BMap.Point(116.404, 39.915), 11);
				var driving = new BMap.DrivingRoute(map, {renderOptions:{map: map, autoViewport: true}});
				driving.search(address, address_map);
			}
			
	    }); 
    </script>
    
</body>
</html>
